home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-portable.exe / quodlibet-3.3.0-portable / data / bin / quodlibet / plugins / editing.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  6KB  |  139 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. from gi.repository import Gtk
  5. from quodlibet.util import connect_obj
  6.  
  7. class RenameFilesPlugin(object):
  8.     """Plugins of this type must subclass a GTK widget. They will be
  9.     packed into the RenameFiles pane (currently a ScrolledWindow hidden
  10.     with an expander, but that might change).
  11.  
  12.     The 'filter' function will be called with the song's original filename
  13.     as a string (probably in the local filesystem encoding) and the proposed
  14.     new filename as a unicode object. It should return an
  15.     appropriate-transformed filename, still as a unicode object.
  16.  
  17.     The plugin must provide either a 'changed' or 'preview'. 'preview'
  18.     causes the entire display to be re-previewed. 'changed' causes the
  19.     Preview button to made sensitive, and Save to be disabled.
  20.  
  21.     If the 'active' attribute is false, the filter will not be called.
  22.     This is particularly useful for gtk.CheckButtons.
  23.  
  24.     The '_order' attribute decides the sort order of the plugin. The
  25.     default filters have orders between 1 and 2. Plugins have order 0 by
  26.     default. Plugins with equal orders are sorted by class name."""
  27.     _order = 0
  28.     active = False
  29.     
  30.     def filter(self, original_filename, value):
  31.         return value
  32.  
  33.     
  34.     def filter_list(self, origs, names):
  35.         return map(self.filter, origs, names)
  36.  
  37.     
  38.     def __cmp__(self, other):
  39.         if not cmp(self._order, other._order):
  40.             pass
  41.         return cmp(type(self).__name__, type(other).__name__)
  42.  
  43.  
  44.  
  45. class TagsFromPathPlugin(object):
  46.     """Plugins of this type must subclass a GTK widget. They will be
  47.     packed into the TagsFromPath pane (currently a ScrolledWindow hidden
  48.     with an expander, but that might change).
  49.  
  50.     The 'filter' function will be called with the tag and proposed value
  51.     as a unicode object. It should return an appropriate-transformed
  52.     filename, still as a unicode object.
  53.  
  54.     If you need to work on a set of filenames at once, you should
  55.     instead overload the 'filter_list' function, which takes two lists;
  56.     one of original filenames, the other of proposed new filenames.
  57.     The default filter_list function calls filter on each item.
  58.  
  59.     The plugin must provide either a 'changed' or 'preview'. 'preview'
  60.     causes the entire display to be re-previewed. 'changed' causes the
  61.     Preview button to made sensitive, and Save to be disabled.
  62.  
  63.     If the 'active' attribute is false, the filter will not be called.
  64.     This is particularly useful for gtk.CheckButtons.
  65.  
  66.     The '_order' attribute decides the sort order of the plugin. The
  67.     default filters have orders between 1 and 2. Plugins have order 0 by
  68.     default. Plugins with equal orders are sorted by class name."""
  69.     _order = 0
  70.     active = False
  71.     
  72.     def filter(self, tag, value):
  73.         return value
  74.  
  75.     
  76.     def __cmp__(self, other):
  77.         if not cmp(self._order, other._order):
  78.             pass
  79.         return cmp(type(self).__name__, type(other).__name__)
  80.  
  81.  
  82.  
  83. class EditTagsPlugin(Gtk.ImageMenuItem):
  84.     """Plugins of this type are subclasses of gtk.ImageMenuItem.
  85.     They will be added to the context menu of the EditTags tree view.
  86.  
  87.     The 'tags' attribute is a list of tags this plugin should appear on,
  88.     or false if it should appear for all tags. This must be a class
  89.     attribute, as it is checked before instantiation.
  90.  
  91.     The 'needs' attribute is a list of tags that must be editable in
  92.     the currently selected songs for the plugin to be sensitive.
  93.  
  94.     The constructor is called with the tag and value for that row. This
  95.     can be used to set the sensitivity of the menu item, or change its
  96.     text.
  97.  
  98.     When clicked, the 'activated' function is called on the object,
  99.     again with the tag name and value. It should return a list of
  100.     (tag, value) tuples to replace the previous tag/value with.
  101.  
  102.     The '_order' attribute decides the sort order of the plugin. The
  103.     default items have orders between 0 and 1. Plugins have order 2.0 by
  104.     default. Plugins with equal orders are sorted by class name.
  105.  
  106.     How to Handle Submenus
  107.     ----------------------
  108.     If the menu item is given a submenu, magic happens. In particular,
  109.     the callbacks are proxied to the submenu's items, and are attached,
  110.     via connect_object, to make sure activated is called on the original
  111.     item.
  112.  
  113.     So, to handle submenus,
  114.       1. Make a submenu and attach it to your menu item.2
  115.       2. To each item in the submenu, attach its 'activate' signal to
  116.          something appropriate to prepare the original item's
  117.          activated method,
  118.       3. Because that method will be called after the subitem is
  119.          clicked on, and your activate handler runs.
  120.     """
  121.     tags = []
  122.     needs = []
  123.     _order = 2
  124.     
  125.     def activated(self, tag, value):
  126.         return [
  127.             (tag, value)]
  128.  
  129.     
  130.     def connect(self, signal, callback, *args, **kwargs):
  131.         if self.get_submenu():
  132.             for item in self.get_submenu().get_children():
  133.                 connect_obj(item, signal, callback, self, *args, **kwargs)
  134.             
  135.         else:
  136.             super(EditTagsPlugin, self).connect(signal, callback, *args, **kwargs)
  137.  
  138.  
  139.